/*
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\version    
\file       sync_event.h
\brief      Sync Event Handling
*/

#ifndef SYNC_EVENT_H
#define SYNC_EVENT_H

#include "event_bus_subscribe.h"

#include <message.h>
#include <sink.h>

/*! \brief Initialises the SyncEvent module
 *  \param init_task Unused
*/
bool SyncEvent_Init(Task init_task);

/*!
    \brief Sets the L2CAP sink for Sync Event wall clock (used for peer synchronization).
    \param Sink sink -L2CAP sink.
*/
void SyncEvent_SetWallClockSink(Sink sink);

/*! \brief Subscribe from an event bus channel.
           Note: Sync Events will fully consume the sync event data
    \param channel - the event bus channel to unsubscribe from.
    \param sync_events - array of events that need to be synchronised
    \param num_sync_events - number of events in array
    \param channel_handler - A function pointer to the channel handler that was previously used to subscribe.
*/
void SyncEvent_SubscribeSyncEvents(event_bus_channel_t channel, const event_bus_event_t sync_events[], uint8 num_sync_events, event_bus_subscriber_t subscriber);

#define SyncEvent_SubscribeSyncEventsArray(channel, sync_events, subscriber) \
    SyncEvent_SubscribeSyncEvents(channel, sync_events, ARRAY_DIM(sync_events), subscriber)

/*! \brief Unsubscribe from an event bus channel.

    \param channel - the event bus channel to unsubscribe from.
    \param channel_handler - A function pointer to the channel handler that was previously used to subscribe.
*/
void SyncEvent_UnsubscribeSyncEvents(event_bus_channel_t channel, const event_bus_event_t sync_events[], uint8 num_sync_events, event_bus_subscriber_t subscriber);

#define SyncEvent_UnsubscribeSyncEventsArray(channel, sync_events, subscriber) \
    SyncEvent_UnsubscribeSyncEvents(channel, sync_events, ARRAY_DIM(sync_events), subscriber)
    
#endif // SYNC_EVENT_H
